package com.igeek.shop.service.admin;

import java.util.List;

import com.igeek.shop.dao.BaseDao;
import com.igeek.shop.entity.Category;
import com.igeek.shop.entity.Product;


public class AdminServiceImpl implements AdminService {
	private BaseDao<Category> dao = new BaseDao<Category>();
	
	@Override
	public List<Category> getCategoryList() {
		String sql ="select * from category";
		Object [] params = {};
		Object list = dao.getList(sql, params, new Category());
		List<Category> categoryList = (List<Category>) list;
		return categoryList;
	}

	@Override
	public void addCategory(Category category) {
		String sql = "insert into category values(?,?)";
		Object [] params = {category.getCid(),category.getCname()};
		dao.update(sql, params);

	}

	@Override
	public Category getCategory(String cid) {
		String sql = "select * from category where cid = ?";
		Object [] params = {cid};
		Category category = (Category) dao.getUserByOne(sql, params, new Category());	
		return category;
	}

	@Override
	public void updateCategory(Category category) {
		String sql = "update category set cname = ? where cid = ?";
		Object [] params = {category.getCname(),category.getCid()};
		dao.update(sql, params);

	}

	@Override
	public void deleteCategory(String cid) {
		String sql = "delete from category where cid = ?";
		Object [] params = {cid};

		dao.update(sql, params);
	}

	

	

	

}
